home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / puma.lha / puma / src / Optimize.mi < prev    next >
Text File  |  1992-09-25  |  43KB  |  1,696 lines

  1. IMPLEMENTATION MODULE Optimize;
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15. IMPORT SYSTEM, System, IO, Tree;
  16. (* line 5 "opt.puma" *)
  17.  
  18.  
  19. FROM IO        IMPORT StdOutput, WriteB, WriteS, WriteI, WriteNl;
  20. FROM Idents    IMPORT WriteIdent;
  21. FROM Mod    IMPORT ImplMod;
  22. FROM Tree    IMPORT tTree, NoTree, mTestIsType, mNodeTypes;
  23. FROM Scanner    IMPORT Warning;
  24. FROM Positions    IMPORT tPosition;
  25.  
  26. FROM Sets    IMPORT
  27.    tSet        , MakeSet    , ReleaseSet    , AssignEmpty    ,
  28.    IsEmpty    , Difference    , IsSubset    , Assign    ,
  29.    IsEqual    , IsNotEqual    , Intersection    , Union        ,
  30.    Size        , WriteSet    ;
  31.  
  32. IMPORT Sets;
  33.  
  34. VAR
  35.    gHasExit, gHasAssign, gHasTargetCode, gHasRejectOrFail: BOOLEAN;
  36.    gRule, nNoDecision, nNoTest    : tTree;
  37.  
  38. PROCEDURE IsDisjoint (s1, s2: tSet): BOOLEAN;
  39.    VAR s: tSet; Result: BOOLEAN;
  40.    BEGIN
  41.       MakeSet (s, Size (s1));
  42.       Assign (s, s1);
  43.       Intersection (s, s2);
  44.       Result := IsEmpty (s);
  45.       ReleaseSet (s);
  46.       RETURN Result;
  47.    END IsDisjoint;
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100. PROCEDURE yyAbort (yyFunction: ARRAY OF CHAR);
  101.  BEGIN
  102.   IO.WriteS (IO.StdError, 'Error: module Optimize, routine ');
  103.   IO.WriteS (IO.StdError, yyFunction);
  104.   IO.WriteS (IO.StdError, ' failed');
  105.   IO.WriteNl (IO.StdError);
  106.   Exit;
  107.  END yyAbort;
  108.  
  109. PROCEDURE yyIsEqual (yya, yyb: ARRAY OF SYSTEM.BYTE): BOOLEAN;
  110.  VAR yyi    : INTEGER;
  111.  BEGIN
  112.   FOR yyi := 0 TO INTEGER (HIGH (yya)) DO
  113.    IF yya [yyi] # yyb [yyi] THEN RETURN FALSE; END;
  114.   END;
  115.   RETURN TRUE;
  116.  END yyIsEqual;
  117.  
  118. PROCEDURE Optimize (t: Tree.tTree);
  119.  VAR yyTempo: RECORD CASE : INTEGER OF
  120.  | 1: yyR1: RECORD
  121.   yyV1: Tree.tTree;
  122.   yyV2: Tree.tTree;
  123.   END;
  124.  | 2: yyR2: RECORD
  125.   yyV1: Tree.tTree;
  126.   yyV2: Tree.tTree;
  127.   yyV3: tSet;
  128.   yyV4: Tree.tTree;
  129.   yyV5: SHORTCARD;
  130.   yyV6: tSet;
  131.   END;
  132.  END; END;
  133.  BEGIN
  134.   IF (t^.Kind = Tree.Spec) THEN
  135. (* line 40 "opt.puma" *)
  136.     WITH yyTempo.yyR1 DO
  137.      WITH t^.Spec DO
  138. (* line 41 "opt.puma" *)
  139.       yyV1 := Tree.yyPoolFreePtr; IF SYSTEM.ADDRESS (yyV1) >= Tree.yyPoolMaxPtr THEN yyV1 := Tree.yyAlloc (); END; INC (Tree.yyPoolFreePtr, Tree.yyNodeSize [Tree.NoDecision]); yyV1^.yyHead.yyMark := 0; yyV1^.Kind := Tree.NoDecision;
  140.       nNoDecision := yyV1;
  141. (* line 42 "opt.puma" *)
  142.       yyV2 := Tree.yyPoolFreePtr; IF SYSTEM.ADDRESS (yyV2) >= Tree.yyPoolMaxPtr THEN yyV2 := Tree.yyAlloc (); END; INC (Tree.yyPoolFreePtr, Tree.yyNodeSize [Tree.NoTest]); yyV2^.yyHead.yyMark := 0; yyV2^.Kind := Tree.NoTest;
  143.       nNoTest := yyV2;
  144. (* line 43 "opt.puma" *)
  145.       Optimize (Routines);
  146.       RETURN;
  147.      END;
  148.     END;
  149.  
  150.   END;
  151.   IF Tree.IsType (t, Tree.Routine) THEN
  152. (* line 45 "opt.puma" *)
  153.     WITH yyTempo.yyR2 DO
  154.      WITH t^.Routine DO
  155. (* line 46 "opt.puma" *)
  156.       RuleProperties (Rules);
  157. (* line 47 "opt.puma" *)
  158.       CollectTests (Rules, InForm);
  159. (* line 48 "opt.puma" *)
  160.       BuildTree (Rules, nNoDecision, yyV1);
  161. (* line 49 "opt.puma" *)
  162.       Decisions := yyV1;
  163. (* line 50 "opt.puma" *)
  164.       ElimDeadTests (Decisions, yyV2, (FALSE), yyV3);
  165. (* line 51 "opt.puma" *)
  166.       FindCases (Decisions, yyV4, yyV5, yyV6);
  167. (* line 52 "opt.puma" *)
  168.       MarkCases (Decisions, yyV5, yyV6);
  169. (* line 53 "opt.puma" *)
  170.       Optimize (Next);
  171.       RETURN;
  172.      END;
  173.     END;
  174.  
  175.   END;
  176.  END Optimize;
  177.  
  178. PROCEDURE RuleProperties (yyP1: Tree.tTree);
  179.  VAR yyTempo: RECORD CASE : INTEGER OF
  180.  END; END;
  181.  BEGIN
  182.  
  183.   CASE yyP1^.Kind OF
  184.   | Tree.Spec:
  185. (* line 58 "opt.puma" *)
  186.      WITH yyP1^.Spec DO
  187. (* line 59 "opt.puma" *)
  188.       RuleProperties (Routines);
  189.       RETURN;
  190.      END;
  191.  
  192.   | Tree.Routine
  193.   , Tree.Procedure
  194.   , Tree.Function
  195.   , Tree.Predicate:
  196. (* line 61 "opt.puma" *)
  197.      WITH yyP1^.Routine DO
  198. (* line 62 "opt.puma" *)
  199.       RuleProperties (Rules);
  200. (* line 63 "opt.puma" *)
  201.       RuleProperties (Next);
  202.       RETURN;
  203.      END;
  204.  
  205.   | Tree.Rule:
  206. (* line 65 "opt.puma" *)
  207.      WITH yyP1^.Rule DO
  208. (* line 66 "opt.puma" *)
  209.       gHasExit := FALSE;
  210. (* line 67 "opt.puma" *)
  211.       gHasAssign := FALSE;
  212. (* line 68 "opt.puma" *)
  213.       gHasTargetCode := FALSE;
  214. (* line 69 "opt.puma" *)
  215.       gHasRejectOrFail := FALSE;
  216. (* line 70 "opt.puma" *)
  217.       RuleProperties (Statements);
  218. (* line 71 "opt.puma" *)
  219.       RuleProperties (Exprs);
  220. (* line 72 "opt.puma" *)
  221.       RuleProperties (Expr);
  222. (* line 73 "opt.puma" *)
  223.       HasExit := gHasExit;
  224. (* line 74 "opt.puma" *)
  225.       HasAssign := gHasAssign;
  226. (* line 75 "opt.puma" *)
  227.       HasTargetCode := gHasTargetCode;
  228. (* line 76 "opt.puma" *)
  229.       HasRejectOrFail := gHasRejectOrFail;
  230. (* line 77 "opt.puma" *)
  231.       RuleProperties (Next);
  232.       RETURN;
  233.      END;
  234.  
  235.   | Tree.ProcCall:
  236. (* line 79 "opt.puma" *)
  237.      WITH yyP1^.ProcCall DO
  238. (* line 80 "opt.puma" *)
  239.       RuleProperties (Call);
  240. (* line 81 "opt.puma" *)
  241.       RuleProperties (Next);
  242.       RETURN;
  243.      END;
  244.  
  245.   | Tree.Assignment:
  246. (* line 83 "opt.puma" *)
  247.      WITH yyP1^.Assignment DO
  248. (* line 84 "opt.puma" *)
  249.       gHasAssign := TRUE;
  250. (* line 85 "opt.puma" *)
  251.       RuleProperties (Adr);
  252. (* line 86 "opt.puma" *)
  253.       RuleProperties (Expr);
  254. (* line 87 "opt.puma" *)
  255.       RuleProperties (Next);
  256.       RETURN;
  257.      END;
  258.  
  259.   | Tree.Condition:
  260. (* line 89 "opt.puma" *)
  261.      WITH yyP1^.Condition DO
  262. (* line 90 "opt.puma" *)
  263.       gHasExit := TRUE;
  264. (* line 91 "opt.puma" *)
  265.       RuleProperties (Next);
  266.       RETURN;
  267.      END;
  268.  
  269.   | Tree.Reject:
  270. (* line 93 "opt.puma" *)
  271.      WITH yyP1^.Reject DO
  272. (* line 94 "opt.puma" *)
  273.       gHasExit := TRUE;
  274. (* line 95 "opt.puma" *)
  275.       gHasRejectOrFail := TRUE;
  276. (* line 96 "opt.puma" *)
  277.       RuleProperties (Next);
  278.       RETURN;
  279.      END;
  280.  
  281.   | Tree.Fail:
  282. (* line 98 "opt.puma" *)
  283.      WITH yyP1^.Fail DO
  284. (* line 99 "opt.puma" *)
  285.       gHasRejectOrFail := TRUE;
  286. (* line 100 "opt.puma" *)
  287.       RuleProperties (Next);
  288.       RETURN;
  289.      END;
  290.  
  291.   | Tree.TargetStmt:
  292. (* line 102 "opt.puma" *)
  293.      WITH yyP1^.TargetStmt DO
  294. (* line 103 "opt.puma" *)
  295.       gHasTargetCode := TRUE;
  296. (* line 104 "opt.puma" *)
  297.       RuleProperties (Next);
  298.       RETURN;
  299.      END;
  300.  
  301.   | Tree.Statement
  302.   , Tree.Nl
  303.   , Tree.WriteStr:
  304. (* line 106 "opt.puma" *)
  305.      WITH yyP1^.Statement DO
  306. (* line 107 "opt.puma" *)
  307.       RuleProperties (Next);
  308.       RETURN;
  309.      END;
  310.  
  311.   | Tree.OneExpr
  312.   , Tree.NamedExpr:
  313. (* line 109 "opt.puma" *)
  314.      WITH yyP1^.OneExpr DO
  315. (* line 110 "opt.puma" *)
  316.       RuleProperties (Expr);
  317. (* line 111 "opt.puma" *)
  318.       RuleProperties (Next);
  319.       RETURN;
  320.      END;
  321.  
  322.   | Tree.Expr
  323.   , Tree.Compose
  324.   , Tree.VarUse
  325.   , Tree.AttrDesc
  326.   , Tree.Nil
  327.   , Tree.Call
  328.   , Tree.Binary
  329.   , Tree.PreOperator
  330.   , Tree.PostOperator
  331.   , Tree.Index
  332.   , Tree.Parents
  333.   , Tree.TargetExpr
  334.   , Tree.StringExpr:
  335. (* line 113 "opt.puma" *)
  336.      WITH yyP1^.Expr DO
  337. (* line 114 "opt.puma" *)
  338.       gHasExit := gHasExit OR NeedsMatch (yyP1);
  339.       RETURN;
  340.      END;
  341.  
  342.   ELSE END;
  343.  
  344.  END RuleProperties;
  345.  
  346. PROCEDURE NeedsMatch (yyP2: Tree.tTree): BOOLEAN;
  347.  VAR yyTempo: RECORD CASE : INTEGER OF
  348.  END; END;
  349.  BEGIN
  350.   IF (yyP2^.Kind = Tree.TestValue) THEN
  351. (* line 119 "opt.puma" *)
  352.    LOOP
  353.      WITH yyP2^.TestValue DO
  354. (* line 119 "opt.puma" *)
  355.       IF NOT (NeedsMatch (Expr) OR NeedsMatch (Next)) THEN EXIT; END;
  356.       RETURN TRUE;
  357.      END;
  358.    END;
  359.  
  360.   END;
  361.  
  362.   CASE yyP2^.Kind OF
  363.   | Tree.OneTest
  364.   , Tree.TestKind
  365.   , Tree.TestIsType
  366.   , Tree.TestNil
  367.   , Tree.TestNonlin
  368.   , Tree.TestValue:
  369. (* line 121 "opt.puma" *)
  370.    LOOP
  371.      WITH yyP2^.OneTest DO
  372. (* line 121 "opt.puma" *)
  373.       IF NOT (NeedsMatch (Next)) THEN EXIT; END;
  374.       RETURN TRUE;
  375.      END;
  376.    END;
  377.  
  378.   | Tree.OneExpr
  379.   , Tree.NamedExpr:
  380. (* line 123 "opt.puma" *)
  381.    LOOP
  382.      WITH yyP2^.OneExpr DO
  383. (* line 123 "opt.puma" *)
  384.       IF NOT (NeedsMatch (Expr) OR NeedsMatch (Next)) THEN EXIT; END;
  385.       RETURN TRUE;
  386.      END;
  387.    END;
  388.  
  389.   | Tree.Compose:
  390. (* line 125 "opt.puma" *)
  391.    LOOP
  392.      WITH yyP2^.Compose DO
  393. (* line 125 "opt.puma" *)
  394.       IF NOT (NeedsMatch (Exprs)) THEN EXIT; END;
  395.       RETURN TRUE;
  396.      END;
  397.    END;
  398.  
  399.   | Tree.Call:
  400. (* line 127 "opt.puma" *)
  401.    LOOP
  402.      WITH yyP2^.Call DO
  403. (* line 128 "opt.puma" *)
  404.       IF NOT (NeedsMatch (Expr) OR NeedsMatch (Exprs) OR (Object # NoTree) AND NeedsMatch2 (Patterns, Object ^ . Routine . OutForm)) THEN EXIT; END;
  405.       RETURN TRUE;
  406.      END;
  407.    END;
  408.  
  409.   | Tree.Binary:
  410. (* line 130 "opt.puma" *)
  411.    LOOP
  412.      WITH yyP2^.Binary DO
  413. (* line 130 "opt.puma" *)
  414.       IF NOT (NeedsMatch (Lop) OR NeedsMatch (Rop)) THEN EXIT; END;
  415.       RETURN TRUE;
  416.      END;
  417.    END;
  418.  
  419.   | Tree.Parents:
  420. (* line 132 "opt.puma" *)
  421.    LOOP
  422.      WITH yyP2^.Parents DO
  423. (* line 134 "opt.puma" *)
  424.       IF NOT (NeedsMatch (Expr)) THEN EXIT; END;
  425.       RETURN TRUE;
  426.      END;
  427.    END;
  428.  
  429.   | Tree.PreOperator:
  430. (* line 132 "opt.puma" *)
  431.    LOOP
  432.      WITH yyP2^.PreOperator DO
  433. (* line 134 "opt.puma" *)
  434.       IF NOT (NeedsMatch (Expr)) THEN EXIT; END;
  435.       RETURN TRUE;
  436.      END;
  437.    END;
  438.  
  439.   | Tree.PostOperator:
  440. (* line 132 "opt.puma" *)
  441.    LOOP
  442.      WITH yyP2^.PostOperator DO
  443. (* line 134 "opt.puma" *)
  444.       IF NOT (NeedsMatch (Expr)) THEN EXIT; END;
  445.       RETURN TRUE;
  446.      END;
  447.    END;
  448.  
  449.   | Tree.Index:
  450. (* line 136 "opt.puma" *)
  451.    LOOP
  452.      WITH yyP2^.Index DO
  453. (* line 136 "opt.puma" *)
  454.       IF NOT (NeedsMatch (Expr) OR NeedsMatch (Exprs)) THEN EXIT; END;
  455.       RETURN TRUE;
  456.      END;
  457.    END;
  458.  
  459.   ELSE END;
  460.  
  461.   RETURN FALSE;
  462.  END NeedsMatch;
  463.  
  464. PROCEDURE NeedsMatch2 (yyP4: Tree.tTree; yyP3: Tree.tTree): BOOLEAN;
  465.  VAR yyTempo: RECORD CASE : INTEGER OF
  466.  END; END;
  467.  BEGIN
  468.   IF (yyP4^.Kind = Tree.OnePattern) THEN
  469. (* line 141 "opt.puma" *)
  470.    LOOP
  471.      WITH yyP4^.OnePattern DO
  472. (* line 142 "opt.puma" *)
  473.       IF NOT (NeedsMatch2 (Pattern, yyP3) OR NeedsMatch2 (Next, yyP3 ^ . Formal . Next)) THEN EXIT; END;
  474.       RETURN TRUE;
  475.      END;
  476.    END;
  477.  
  478.   END;
  479.   IF (yyP4^.Kind = Tree.Decompose) THEN
  480. (* line 145 "opt.puma" *)
  481.    LOOP
  482.      WITH yyP4^.Decompose DO
  483.      WITH yyP3^.Formal DO
  484. (* line 147 "opt.puma" *)
  485.       IF NOT ((yyP3^.Formal.TypeDesc ^ . Kind = Tree . UserType) OR IsNotEqual (Object ^ . Class . TypeDesc ^ . NodeTypes . Types, yyP3^.Formal.TypeDesc ^ . NodeTypes . Types) OR NeedsMatch2 (Patterns, Object ^ . Class . Formals)) THEN EXIT; END;
  486.       RETURN TRUE;
  487.      END;
  488.      END;
  489.    END;
  490.  
  491.   END;
  492.   IF (yyP4^.Kind = Tree.VarDef) THEN
  493. (* line 150 "opt.puma" *)
  494.    LOOP
  495.      WITH yyP4^.VarDef DO
  496. (* line 150 "opt.puma" *)
  497.       IF NOT (Object # NoTree) THEN EXIT; END;
  498.       RETURN TRUE;
  499.      END;
  500.    END;
  501.  
  502.   END;
  503.   IF (yyP4^.Kind = Tree.NilTest) THEN
  504. (* line 151 "opt.puma" *)
  505.       RETURN TRUE;
  506.  
  507.   END;
  508.   IF (yyP4^.Kind = Tree.Value) THEN
  509. (* line 152 "opt.puma" *)
  510.       RETURN TRUE;
  511.  
  512.   END;
  513.   RETURN FALSE;
  514.  END NeedsMatch2;
  515.  
  516. PROCEDURE NeedsTempo (yyP5: Tree.tTree; VAR yyP6: Tree.tTree): BOOLEAN;
  517.  VAR yyTempo: RECORD CASE : INTEGER OF
  518.  | 1: yyR1: RECORD
  519.   yyV1: Tree.tTree;
  520.   END;
  521.  END; END;
  522.  BEGIN
  523.   IF (yyP5^.Kind = Tree.Decision) THEN
  524. (* line 156 "opt.puma" *)
  525.     WITH yyTempo.yyR1 DO
  526.    LOOP
  527.      WITH yyP5^.Decision DO
  528. (* line 156 "opt.puma" *)
  529.       IF NOT (NeedsTempo (yyP5^.Decision.Then, yyV1)) THEN EXIT; END;
  530.       yyP6 := yyV1;
  531.       RETURN TRUE;
  532.      END;
  533.    END;
  534.     END;
  535.  
  536.   END;
  537.   IF (yyP5^.Kind = Tree.Decided) THEN
  538.   IF (yyP5^.Decided.Rule^.Rule.HasTempos =  (TRUE)) THEN
  539. (* line 157 "opt.puma" *)
  540.       yyP6 := yyP5^.Decided.Rule;
  541.       RETURN TRUE;
  542.  
  543.   END;
  544.   END;
  545.   RETURN FALSE;
  546.  END NeedsTempo;
  547.  
  548. PROCEDURE NeedsNoFinale (yyP7: Tree.tTree): BOOLEAN;
  549.  VAR yyTempo: RECORD CASE : INTEGER OF
  550.  END; END;
  551.  BEGIN
  552.   IF (yyP7^.Kind = Tree.Decision) THEN
  553. (* line 161 "opt.puma" *)
  554.    LOOP
  555.      WITH yyP7^.Decision DO
  556. (* line 161 "opt.puma" *)
  557.       IF NOT (NeedsNoFinale (yyP7^.Decision.Else)) THEN EXIT; END;
  558.       RETURN TRUE;
  559.      END;
  560.    END;
  561.  
  562.   END;
  563.   IF (yyP7^.Kind = Tree.Decided) THEN
  564.   IF (yyP7^.Decided.Rule^.Rule.HasExit =  (FALSE)) THEN
  565. (* line 162 "opt.puma" *)
  566.       RETURN TRUE;
  567.  
  568.   END;
  569. (* line 163 "opt.puma" *)
  570.    LOOP
  571.      WITH yyP7^.Decided DO
  572. (* line 163 "opt.puma" *)
  573.       IF NOT (NeedsNoFinale (yyP7^.Decided.Else)) THEN EXIT; END;
  574.       RETURN TRUE;
  575.      END;
  576.    END;
  577.  
  578.   END;
  579.   RETURN FALSE;
  580.  END NeedsNoFinale;
  581.  
  582. PROCEDURE GetRule (yyP8: Tree.tTree; VAR yyP9: Tree.tTree);
  583.  VAR yyTempo: RECORD CASE : INTEGER OF
  584.  | 1: yyR1: RECORD
  585.   yyV1: Tree.tTree;
  586.   END;
  587.  END; END;
  588.  BEGIN
  589.   IF (yyP8^.Kind = Tree.Decision) THEN
  590. (* line 167 "opt.puma" *)
  591.     WITH yyTempo.yyR1 DO
  592.      WITH yyP8^.Decision DO
  593. (* line 167 "opt.puma" *)
  594.       GetRule (yyP8^.Decision.Then, yyV1);
  595.       yyP9 := yyV1;
  596.       RETURN;
  597.      END;
  598.     END;
  599.  
  600.   END;
  601.   IF (yyP8^.Kind = Tree.Decided) THEN
  602. (* line 168 "opt.puma" *)
  603.       yyP9 := yyP8^.Decided.Rule;
  604.       RETURN;
  605.  
  606.   END;
  607.  END GetRule;
  608.  
  609. PROCEDURE CollectTests (yyP11: Tree.tTree; yyP10: Tree.tTree);
  610.  VAR yyTempo: RECORD CASE : INTEGER OF
  611.  | 1: yyR1: RECORD
  612.   yyV1: Tree.tTree;
  613.   END;
  614.  END; END;
  615.  BEGIN
  616.   IF (yyP11^.Kind = Tree.Rule) THEN
  617. (* line 172 "opt.puma" *)
  618.     WITH yyTempo.yyR1 DO
  619.      WITH yyP11^.Rule DO
  620. (* line 173 "opt.puma" *)
  621.       CollectTests2 (Patterns, yyP10, nNoTest, yyV1);
  622. (* line 174 "opt.puma" *)
  623.       Tests := yyV1;
  624. (* line 175 "opt.puma" *)
  625.       CollectTests (Next, yyP10);
  626.       RETURN;
  627.      END;
  628.     END;
  629.  
  630.   END;
  631.  END CollectTests;
  632.  
  633. PROCEDURE CollectTests2 (yyP14: Tree.tTree; yyP13: Tree.tTree; yyP12: Tree.tTree; VAR yyP15: Tree.tTree);
  634.  VAR yyTempo: RECORD CASE : INTEGER OF
  635.  | 1: yyR1: RECORD
  636.   yyV1: Tree.tTree;
  637.   yyV2: Tree.tTree;
  638.   END;
  639.  | 2: yyR2: RECORD
  640.   yyV1: Tree.tTree;
  641.   END;
  642.  | 3: yyR3: RECORD
  643.   yyV1: Tree.tTree;
  644.   END;
  645.  | 4: yyR4: RECORD
  646.   yyV1: Tree.tTree;
  647.   END;
  648.  END; END;
  649.  BEGIN
  650.   IF (yyP14^.Kind = Tree.OnePattern) THEN
  651.   IF (yyP13^.Kind = Tree.Formal) THEN
  652. (* line 180 "opt.puma" *)
  653.     WITH yyTempo.yyR1 DO
  654.      WITH yyP14^.OnePattern DO
  655.      WITH yyP13^.Formal DO
  656. (* line 182 "opt.puma" *)
  657.       CollectTests2 (yyP14^.OnePattern.Next, yyP13^.Formal.Next, yyP12, yyV1);
  658. (* line 183 "opt.puma" *)
  659.       CollectTests2 (yyP14^.OnePattern.Pattern, yyP13, yyV1, yyV2);
  660.       yyP15 := yyV2;
  661.       RETURN;
  662.      END;
  663.      END;
  664.     END;
  665.  
  666.   END;
  667.   END;
  668.   IF (yyP14^.Kind = Tree.Decompose) THEN
  669.   IF (yyP13^.Kind = Tree.Formal) THEN
  670. (* line 185 "opt.puma" *)
  671.     WITH yyTempo.yyR2 DO
  672.    LOOP
  673.      WITH yyP14^.Decompose DO
  674.      WITH yyP13^.Formal DO
  675. (* line 187 "opt.puma" *)
  676.       IF NOT ((yyP13^.Formal.TypeDesc ^ . Kind # Tree . UserType) AND IsEqual (Object ^ . Class . TypeDesc ^ . NodeTypes . Types, yyP13^.Formal.TypeDesc ^ . NodeTypes . Types)) THEN EXIT; END;
  677. (* line 189 "opt.puma" *)
  678.       CollectTests2 (Patterns, Object ^ . Class . Formals, yyP12, yyV1);
  679.       yyP15 := yyV1;
  680.       RETURN;
  681.      END;
  682.      END;
  683.    END;
  684.     END;
  685.  
  686. (* line 191 "opt.puma" *)
  687.     WITH yyTempo.yyR3 DO
  688.    LOOP
  689.      WITH yyP14^.Decompose DO
  690.      WITH yyP13^.Formal DO
  691. (* line 193 "opt.puma" *)
  692.       IF NOT (yyP14^.Decompose.Object ^ . Class . Extensions ^ . Kind = Tree . NoClass) THEN EXIT; END;
  693. (* line 194 "opt.puma" *)
  694.       CollectTests2 (yyP14^.Decompose.Patterns, yyP14^.Decompose.Object ^ . Class . Formals, yyP12, yyV1);
  695.       yyP15 := Tree.yyPoolFreePtr; IF SYSTEM.ADDRESS (yyP15) >= Tree.yyPoolMaxPtr THEN yyP15 := Tree.yyAlloc (); END; INC (Tree.yyPoolFreePtr, Tree.yyNodeSize [Tree.TestKind]); yyP15^.yyHead.yyMark := 0; yyP15^.Kind := Tree.TestKind;
  696.       WITH yyP15^.TestKind DO
  697.       Next := yyV1;
  698.       Path := yyP14^.Decompose.Path;
  699.       TypeDesc := yyP14^.Decompose.Object ^ . Class . TypeDesc;
  700.       Name := yyP14^.Decompose.Object ^ . Class . Name;
  701.       END;
  702.       RETURN;
  703.      END;
  704.      END;
  705.    END;
  706.     END;
  707.  
  708.   END;
  709. (* line 196 "opt.puma" *)
  710.     WITH yyTempo.yyR4 DO
  711.      WITH yyP14^.Decompose DO
  712. (* line 198 "opt.puma" *)
  713.       CollectTests2 (yyP14^.Decompose.Patterns, yyP14^.Decompose.Object ^ . Class . Formals, yyP12, yyV1);
  714.       yyP15 := Tree.yyPoolFreePtr; IF SYSTEM.ADDRESS (yyP15) >= Tree.yyPoolMaxPtr THEN yyP15 := Tree.yyAlloc (); END; INC (Tree.yyPoolFreePtr, Tree.yyNodeSize [Tree.TestIsType]); yyP15^.yyHead.yyMark := 0; yyP15^.Kind := Tree.TestIsType;
  715.       WITH yyP15^.TestIsType DO
  716.       Next := yyV1;
  717.       Path := yyP14^.Decompose.Path;
  718.       TypeDesc := yyP14^.Decompose.Object ^ . Class . TypeDesc;
  719.       Name := yyP14^.Decompose.Object ^ . Class . Name;
  720.       END;
  721.       RETURN;
  722.      END;
  723.     END;
  724.  
  725.   END;
  726.   IF (yyP14^.Kind = Tree.VarDef) THEN
  727. (* line 200 "opt.puma" *)
  728.    LOOP
  729.      WITH yyP14^.VarDef DO
  730. (* line 202 "opt.puma" *)
  731.       IF NOT (Object # NoTree) THEN EXIT; END;
  732.       yyP15 := Tree.yyPoolFreePtr; IF SYSTEM.ADDRESS (yyP15) >= Tree.yyPoolMaxPtr THEN yyP15 := Tree.yyAlloc (); END; INC (Tree.yyPoolFreePtr, Tree.yyNodeSize [Tree.TestNonlin]); yyP15^.yyHead.yyMark := 0; yyP15^.Kind := Tree.TestNonlin;
  733.       WITH yyP15^.TestNonlin DO
  734.       Next := yyP12;
  735.       Path := Object ^ . Formal . Path;
  736.       Path2 := yyP14^.VarDef.Path;
  737.       TypeDesc := Object ^ . Formal . TypeDesc;
  738.       END;
  739.       RETURN;
  740.      END;
  741.    END;
  742.  
  743.   END;
  744.   IF (yyP14^.Kind = Tree.NilTest) THEN
  745. (* line 204 "opt.puma" *)
  746.       yyP15 := Tree.yyPoolFreePtr; IF SYSTEM.ADDRESS (yyP15) >= Tree.yyPoolMaxPtr THEN yyP15 := Tree.yyAlloc (); END; INC (Tree.yyPoolFreePtr, Tree.yyNodeSize [Tree.TestNil]); yyP15^.yyHead.yyMark := 0; yyP15^.Kind := Tree.TestNil;
  747.       WITH yyP15^.TestNil DO
  748.       Next := yyP12;
  749.       Path := yyP14^.NilTest.Path;
  750.       END;
  751.       RETURN;
  752.  
  753.   END;
  754.   IF (yyP14^.Kind = Tree.Value) THEN
  755.   IF (yyP13^.Kind = Tree.Formal) THEN
  756. (* line 207 "opt.puma" *)
  757.       yyP15 := Tree.yyPoolFreePtr; IF SYSTEM.ADDRESS (yyP15) >= Tree.yyPoolMaxPtr THEN yyP15 := Tree.yyAlloc (); END; INC (Tree.yyPoolFreePtr, Tree.yyNodeSize [Tree.TestValue]); yyP15^.yyHead.yyMark := 0; yyP15^.Kind := Tree.TestValue;
  758.       WITH yyP15^.TestValue DO
  759.       Next := yyP12;
  760.       Path := yyP14^.Value.Path;
  761.       Expr := yyP14^.Value.Expr;
  762.       TypeDesc := yyP13 ^ . Formal . TypeDesc;
  763.       END;
  764.       RETURN;
  765.  
  766.   END;
  767.   END;
  768. (* line 210 "opt.puma" *)
  769.       yyP15 := yyP12;
  770.       RETURN;
  771.  
  772.  END CollectTests2;
  773.  
  774. PROCEDURE IsSamePath (yyP17: Tree.tTree; yyP16: Tree.tTree): BOOLEAN;
  775.  VAR yyTempo: RECORD CASE : INTEGER OF
  776.  END; END;
  777.  BEGIN
  778.   IF (yyP17^.Kind = Tree.Var) THEN
  779.   IF (yyP16^.Kind = Tree.Var) THEN
  780.   IF (yyP17^.Var.Name =  yyP16^.Var.Name) THEN
  781. (* line 215 "opt.puma" *)
  782.       RETURN TRUE;
  783.  
  784.   END;
  785.   END;
  786.   END;
  787.   IF (yyP17^.Kind = Tree.ConsType) THEN
  788.   IF (yyP16^.Kind = Tree.ConsType) THEN
  789.   IF (yyP17^.ConsType.Name =  yyP16^.ConsType.Name) THEN
  790. (* line 216 "opt.puma" *)
  791.    LOOP
  792.      WITH yyP17^.ConsType DO
  793.      WITH yyP16^.ConsType DO
  794. (* line 217 "opt.puma" *)
  795.       IF NOT (IsSamePath (yyP17^.ConsType.Next, yyP16^.ConsType.Next)) THEN EXIT; END;
  796.       RETURN TRUE;
  797.      END;
  798.      END;
  799.    END;
  800.  
  801.   END;
  802.   END;
  803.   END;
  804.   IF (yyP17^.Kind = Tree.Field) THEN
  805.   IF (yyP16^.Kind = Tree.Field) THEN
  806.   IF (yyP17^.Field.Name =  yyP16^.Field.Name) THEN
  807. (* line 216 "opt.puma" *)
  808.    LOOP
  809.      WITH yyP17^.Field DO
  810.      WITH yyP16^.Field DO
  811. (* line 217 "opt.puma" *)
  812.       IF NOT (IsSamePath (yyP17^.Field.Next, yyP16^.Field.Next)) THEN EXIT; END;
  813.       RETURN TRUE;
  814.      END;
  815.      END;
  816.    END;
  817.  
  818.   END;
  819.   END;
  820.   END;
  821.   RETURN FALSE;
  822.  END IsSamePath;
  823.  
  824. PROCEDURE IsSameType (yyP19: Tree.tTree; yyP18: Tree.tTree): BOOLEAN;
  825.  VAR yyTempo: RECORD CASE : INTEGER OF
  826.  END; END;
  827.  BEGIN
  828.   IF (yyP19^.Kind = Tree.NodeTypes) THEN
  829.   IF (yyP18^.Kind = Tree.NodeTypes) THEN
  830.   IF (yyP19^.NodeTypes.TreeName^.TreeName.Name =  yyP18^.NodeTypes.TreeName^.TreeName.Name) THEN
  831.   IF (Sets.IsEqual (yyP19^.NodeTypes.Types,  yyP18^.NodeTypes.Types)) THEN
  832. (* line 221 "opt.puma" *)
  833.       RETURN TRUE;
  834.  
  835.   END;
  836.   END;
  837.   END;
  838.   END;
  839.   IF (yyP19^.Kind = Tree.UserType) THEN
  840.   IF (yyP18^.Kind = Tree.UserType) THEN
  841.   IF (yyP19^.UserType.Type =  yyP18^.UserType.Type) THEN
  842. (* line 222 "opt.puma" *)
  843.       RETURN TRUE;
  844.  
  845.   END;
  846.   END;
  847.   END;
  848.   RETURN FALSE;
  849.  END IsSameType;
  850.  
  851. PROCEDURE IsSameTest (yyP21: Tree.tTree; yyP20: Tree.tTree): BOOLEAN;
  852.  VAR yyTempo: RECORD CASE : INTEGER OF
  853.  END; END;
  854.  BEGIN
  855.   IF (yyP21^.Kind = Tree.TestKind) THEN
  856.   IF (yyP20^.Kind = Tree.TestKind) THEN
  857. (* line 226 "opt.puma" *)
  858.    LOOP
  859.      WITH yyP21^.TestKind DO
  860.      WITH yyP20^.TestKind DO
  861. (* line 228 "opt.puma" *)
  862.       IF NOT (IsSamePath (yyP21^.TestKind.Path, yyP20^.TestKind.Path)) THEN EXIT; END;
  863. (* line 229 "opt.puma" *)
  864.       IF NOT (IsSameType (yyP21^.TestKind.TypeDesc, yyP20^.TestKind.TypeDesc)) THEN EXIT; END;
  865.       RETURN TRUE;
  866.      END;
  867.      END;
  868.    END;
  869.  
  870.   END;
  871.   END;
  872.   IF (yyP21^.Kind = Tree.TestIsType) THEN
  873.   IF (yyP20^.Kind = Tree.TestIsType) THEN
  874. (* line 226 "opt.puma" *)
  875.    LOOP
  876.      WITH yyP21^.TestIsType DO
  877.      WITH yyP20^.TestIsType DO
  878. (* line 228 "opt.puma" *)
  879.       IF NOT (IsSamePath (yyP21^.TestIsType.Path, yyP20^.TestIsType.Path)) THEN EXIT; END;
  880. (* line 229 "opt.puma" *)
  881.       IF NOT (IsSameType (yyP21^.TestIsType.TypeDesc, yyP20^.TestIsType.TypeDesc)) THEN EXIT; END;
  882.       RETURN TRUE;
  883.      END;
  884.      END;
  885.    END;
  886.  
  887.   END;
  888.   END;
  889.   IF (yyP21^.Kind = Tree.TestNil) THEN
  890.   IF (yyP20^.Kind = Tree.TestNil) THEN
  891. (* line 231 "opt.puma" *)
  892.    LOOP
  893.      WITH yyP21^.TestNil DO
  894.      WITH yyP20^.TestNil DO
  895. (* line 232 "opt.puma" *)
  896.       IF NOT (IsSamePath (yyP21^.TestNil.Path, yyP20^.TestNil.Path)) THEN EXIT; END;
  897.       RETURN TRUE;
  898.      END;
  899.      END;
  900.    END;
  901.  
  902.   END;
  903.   END;
  904.   IF (yyP21^.Kind = Tree.TestNonlin) THEN
  905.   IF (yyP20^.Kind = Tree.TestNonlin) THEN
  906. (* line 234 "opt.puma" *)
  907.    LOOP
  908.      WITH yyP21^.TestNonlin DO
  909.      WITH yyP20^.TestNonlin DO
  910. (* line 235 "opt.puma" *)
  911.       IF NOT (IsSamePath (yyP21^.TestNonlin.Path, yyP20^.TestNonlin.Path)) THEN EXIT; END;
  912. (* line 236 "opt.puma" *)
  913.       IF NOT (IsSamePath (yyP21^.TestNonlin.Path2, yyP20^.TestNonlin.Path2)) THEN EXIT; END;
  914.       RETURN TRUE;
  915.      END;
  916.      END;
  917.    END;
  918.  
  919.   END;
  920.   END;
  921.   RETURN FALSE;
  922.  END IsSameTest;
  923.  
  924. PROCEDURE BuildTree (yyP23: Tree.tTree; yyP22: Tree.tTree; VAR yyP24: Tree.tTree);
  925.  VAR yyTempo: RECORD CASE : INTEGER OF
  926.  | 1: yyR1: RECORD
  927.   yyV1: Tree.tTree;
  928.   yyV2: Tree.tTree;
  929.   END;
  930.  END; END;
  931.  BEGIN
  932.   IF (yyP23^.Kind = Tree.Rule) THEN
  933. (* line 241 "opt.puma" *)
  934.     WITH yyTempo.yyR1 DO
  935.      WITH yyP23^.Rule DO
  936. (* line 242 "opt.puma" *)
  937.       gRule := yyP23;
  938. (* line 243 "opt.puma" *)
  939.       BuildTree2 (Tests, yyP22, yyV1);
  940. (* line 244 "opt.puma" *)
  941.       UpdateChange (yyV1, gRule);
  942. (* line 245 "opt.puma" *)
  943.       BuildTree (Next, yyV1, yyV2);
  944.       yyP24 := yyV2;
  945.       RETURN;
  946.      END;
  947.     END;
  948.  
  949.   END;
  950.   IF (yyP23^.Kind = Tree.NoRule) THEN
  951. (* line 247 "opt.puma" *)
  952.       yyP24 := yyP22;
  953.       RETURN;
  954.  
  955.   END;
  956.  END BuildTree;
  957.  
  958. PROCEDURE BuildTree2 (t: Tree.tTree; d: Tree.tTree; VAR yyP25: Tree.tTree);
  959.  VAR yyTempo: RECORD CASE : INTEGER OF
  960.  | 1: yyR1: RECORD
  961.   yyV1: Tree.tTree;
  962.   END;
  963.  | 2: yyR2: RECORD
  964.   yyV1: Tree.tTree;
  965.   END;
  966.  | 3: yyR3: RECORD
  967.   yyV1: Tree.tTree;
  968.   END;
  969.  | 4: yyR4: RECORD
  970.   yyV1: Tree.tTree;
  971.   END;
  972.  | 6: yyR6: RECORD
  973.   yyV1: Tree.tTree;
  974.   END;
  975.  | 7: yyR7: RECORD
  976.   yyV1: Tree.tTree;
  977.   END;
  978.  END; END;
  979.  BEGIN
  980.   IF Tree.IsType (t, Tree.OneTest) THEN
  981.   IF (d^.Kind = Tree.NoDecision) THEN
  982. (* line 252 "opt.puma" *)
  983.     WITH yyTempo.yyR1 DO
  984.      WITH t^.OneTest DO
  985.      WITH d^.NoDecision DO
  986. (* line 253 "opt.puma" *)
  987.       BuildTree2 (t^.OneTest.Next, d, yyV1);
  988. (* line 254 "opt.puma" *)
  989.       UpdateChange (yyV1, gRule);
  990.       yyP25 := Tree.yyPoolFreePtr; IF SYSTEM.ADDRESS (yyP25) >= Tree.yyPoolMaxPtr THEN yyP25 := Tree.yyAlloc (); END; INC (Tree.yyPoolFreePtr, Tree.yyNodeSize [Tree.Decision]); yyP25^.yyHead.yyMark := 0; yyP25^.Kind := Tree.Decision;
  991.       WITH yyP25^.Decision DO
  992.       Then := yyV1;
  993.       Else := d;
  994.       OneTest := t;
  995.       Cases := 0;
  996.       IsUnchanged := TRUE;
  997.       END;
  998.       RETURN;
  999.      END;
  1000.      END;
  1001.     END;
  1002.  
  1003.   END;
  1004.   IF (d^.Kind = Tree.Decision) THEN
  1005.     WITH yyTempo.yyR2 DO
  1006.   IF (d^.Decision.IsUnchanged =  (TRUE)) THEN
  1007. (* line 256 "opt.puma" *)
  1008.    LOOP
  1009.      WITH t^.OneTest DO
  1010.      WITH d^.Decision DO
  1011. (* line 257 "opt.puma" *)
  1012.       IF NOT (IsSameTest (t, d^.Decision.OneTest)) THEN EXIT; END;
  1013. (* line 258 "opt.puma" *)
  1014.       IF NOT (NOT HasInterference (t, d^.Decision.Else)) THEN EXIT; END;
  1015. (* line 259 "opt.puma" *)
  1016.       BuildTree2 (t^.OneTest.Next, d^.Decision.Then, yyV1);
  1017. (* line 260 "opt.puma" *)
  1018.       d^.Decision.Then := yyV1;
  1019. (* line 261 "opt.puma" *)
  1020.       UpdateChange (yyV1, gRule);
  1021.       yyP25 := d;
  1022.       RETURN;
  1023.      END;
  1024.      END;
  1025.    END;
  1026.  
  1027.   END;
  1028.     END;
  1029. (* line 263 "opt.puma" *)
  1030.     WITH yyTempo.yyR3 DO
  1031.      WITH t^.OneTest DO
  1032.      WITH d^.Decision DO
  1033. (* line 264 "opt.puma" *)
  1034.       BuildTree2 (t, d^.Decision.Else, yyV1);
  1035. (* line 265 "opt.puma" *)
  1036.       d^.Decision.Else := yyV1;
  1037. (* line 266 "opt.puma" *)
  1038.       UpdateChange (yyV1, gRule);
  1039.       yyP25 := d;
  1040.       RETURN;
  1041.      END;
  1042.      END;
  1043.     END;
  1044.  
  1045.   END;
  1046.   IF (d^.Kind = Tree.Decided) THEN
  1047. (* line 268 "opt.puma" *)
  1048.     WITH yyTempo.yyR4 DO
  1049.      WITH t^.OneTest DO
  1050.      WITH d^.Decided DO
  1051. (* line 269 "opt.puma" *)
  1052.       BuildTree2 (t, d^.Decided.Else, yyV1);
  1053. (* line 270 "opt.puma" *)
  1054.       d^.Decided.Else := yyV1;
  1055. (* line 271 "opt.puma" *)
  1056.       UpdateChange (yyV1, gRule);
  1057.       yyP25 := d;
  1058.       RETURN;
  1059.      END;
  1060.      END;
  1061.     END;
  1062.  
  1063.   END;
  1064.   END;
  1065.   IF (t^.Kind = Tree.NoTest) THEN
  1066.   IF (d^.Kind = Tree.NoDecision) THEN
  1067. (* line 273 "opt.puma" *)
  1068.       yyP25 := Tree.yyPoolFreePtr; IF SYSTEM.ADDRESS (yyP25) >= Tree.yyPoolMaxPtr THEN yyP25 := Tree.yyAlloc (); END; INC (Tree.yyPoolFreePtr, Tree.yyNodeSize [Tree.Decided]); yyP25^.yyHead.yyMark := 0; yyP25^.Kind := Tree.Decided;
  1069.       WITH yyP25^.Decided DO
  1070.       Else := d;
  1071.       Rule := gRule;
  1072.       END;
  1073.       RETURN;
  1074.  
  1075.   END;
  1076.   IF (d^.Kind = Tree.Decision) THEN
  1077. (* line 275 "opt.puma" *)
  1078.     WITH yyTempo.yyR6 DO
  1079.      WITH t^.NoTest DO
  1080.      WITH d^.Decision DO
  1081. (* line 276 "opt.puma" *)
  1082.       BuildTree2 (t, d^.Decision.Else, yyV1);
  1083. (* line 277 "opt.puma" *)
  1084.       d^.Decision.Else := yyV1;
  1085.       yyP25 := d;
  1086.       RETURN;
  1087.      END;
  1088.      END;
  1089.     END;
  1090.  
  1091.   END;
  1092.   IF (d^.Kind = Tree.Decided) THEN
  1093. (* line 279 "opt.puma" *)
  1094.     WITH yyTempo.yyR7 DO
  1095.      WITH t^.NoTest DO
  1096.      WITH d^.Decided DO
  1097. (* line 280 "opt.puma" *)
  1098.       BuildTree2 (t, d^.Decided.Else, yyV1);
  1099. (* line 281 "opt.puma" *)
  1100.       d^.Decided.Else := yyV1;
  1101.       yyP25 := d;
  1102.       RETURN;
  1103.      END;
  1104.      END;
  1105.     END;
  1106.  
  1107.   END;
  1108.   END;
  1109.  END BuildTree2;
  1110.  
  1111. PROCEDURE HasInterference (yyP27: Tree.tTree; yyP26: Tree.tTree): BOOLEAN;
  1112.  VAR yyTempo: RECORD CASE : INTEGER OF
  1113.  END; END;
  1114.  BEGIN
  1115.   IF (yyP26^.Kind = Tree.Decided) THEN
  1116. (* line 286 "opt.puma" *)
  1117.       RETURN TRUE;
  1118.  
  1119.   END;
  1120.   IF (yyP27^.Kind = Tree.TestKind) THEN
  1121.   IF (yyP26^.Kind = Tree.Decision) THEN
  1122.   IF (yyP26^.Decision.OneTest^.Kind = Tree.TestKind) THEN
  1123. (* line 287 "opt.puma" *)
  1124.    LOOP
  1125.      WITH yyP27^.TestKind DO
  1126.      WITH yyP26^.Decision DO
  1127. (* line 295 "opt.puma" *)
  1128.       IF NOT (IsSamePath (yyP27^.TestKind.Path, yyP26^.Decision.OneTest^.TestKind.Path)) THEN EXIT; END;
  1129. (* line 296 "opt.puma" *)
  1130.       IF NOT (NOT IsDisjoint (yyP27^.TestKind.TypeDesc^.NodeTypes.Types, yyP26^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.Types)) THEN EXIT; END;
  1131.       RETURN TRUE;
  1132.      END;
  1133.      END;
  1134.    END;
  1135.  
  1136.   END;
  1137.   IF (yyP26^.Decision.OneTest^.Kind = Tree.TestIsType) THEN
  1138. (* line 287 "opt.puma" *)
  1139.    LOOP
  1140.      WITH yyP27^.TestKind DO
  1141.      WITH yyP26^.Decision DO
  1142. (* line 295 "opt.puma" *)
  1143.       IF NOT (IsSamePath (yyP27^.TestKind.Path, yyP26^.Decision.OneTest^.TestIsType.Path)) THEN EXIT; END;
  1144. (* line 296 "opt.puma" *)
  1145.       IF NOT (NOT IsDisjoint (yyP27^.TestKind.TypeDesc^.NodeTypes.Types, yyP26^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.Types)) THEN EXIT; END;
  1146.       RETURN TRUE;
  1147.      END;
  1148.      END;
  1149.    END;
  1150.  
  1151.   END;
  1152.   END;
  1153.   END;
  1154.   IF (yyP27^.Kind = Tree.TestIsType) THEN
  1155.   IF (yyP26^.Kind = Tree.Decision) THEN
  1156.   IF (yyP26^.Decision.OneTest^.Kind = Tree.TestKind) THEN
  1157. (* line 287 "opt.puma" *)
  1158.    LOOP
  1159.      WITH yyP27^.TestIsType DO
  1160.      WITH yyP26^.Decision DO
  1161. (* line 295 "opt.puma" *)
  1162.       IF NOT (IsSamePath (yyP27^.TestIsType.Path, yyP26^.Decision.OneTest^.TestKind.Path)) THEN EXIT; END;
  1163. (* line 296 "opt.puma" *)
  1164.       IF NOT (NOT IsDisjoint (yyP27^.TestIsType.TypeDesc^.NodeTypes.Types, yyP26^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.Types)) THEN EXIT; END;
  1165.       RETURN TRUE;
  1166.      END;
  1167.      END;
  1168.    END;
  1169.  
  1170.   END;
  1171.   IF (yyP26^.Decision.OneTest^.Kind = Tree.TestIsType) THEN
  1172. (* line 287 "opt.puma" *)
  1173.    LOOP
  1174.      WITH yyP27^.TestIsType DO
  1175.      WITH yyP26^.Decision DO
  1176. (* line 295 "opt.puma" *)
  1177.       IF NOT (IsSamePath (yyP27^.TestIsType.Path, yyP26^.Decision.OneTest^.TestIsType.Path)) THEN EXIT; END;
  1178. (* line 296 "opt.puma" *)
  1179.       IF NOT (NOT IsDisjoint (yyP27^.TestIsType.TypeDesc^.NodeTypes.Types, yyP26^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.Types)) THEN EXIT; END;
  1180.       RETURN TRUE;
  1181.      END;
  1182.      END;
  1183.    END;
  1184.  
  1185.   END;
  1186.   END;
  1187.   END;
  1188.   IF (yyP26^.Kind = Tree.Decision) THEN
  1189. (* line 298 "opt.puma" *)
  1190.    LOOP
  1191.      WITH yyP26^.Decision DO
  1192. (* line 298 "opt.puma" *)
  1193.       IF NOT (HasInterference (yyP27, yyP26^.Decision.Else)) THEN EXIT; END;
  1194.       RETURN TRUE;
  1195.      END;
  1196.    END;
  1197.  
  1198.   END;
  1199.   RETURN FALSE;
  1200.  END HasInterference;
  1201.  
  1202. PROCEDURE UpdateChange (yyP29: Tree.tTree; yyP28: Tree.tTree);
  1203.  VAR yyTempo: RECORD CASE : INTEGER OF
  1204.  END; END;
  1205.  BEGIN
  1206.   IF (yyP29^.Kind = Tree.Decision) THEN
  1207.   IF (yyP29^.Decision.OneTest^.Kind = Tree.TestKind) THEN
  1208.   IF (yyP28^.Rule.HasExit =  (TRUE)) THEN
  1209.   IF (yyP28^.Rule.HasAssign =  (TRUE)) THEN
  1210. (* line 302 "opt.puma" *)
  1211.    LOOP
  1212.      WITH yyP29^.Decision DO
  1213.      WITH yyP28^.Rule DO
  1214. (* line 306 "opt.puma" *)
  1215.       IF NOT (IsChanged (yyP29^.Decision.OneTest^.TestKind.Path, yyP28^.Rule.Statements)) THEN EXIT; END;
  1216. (* line 307 "opt.puma" *)
  1217.       yyP29^.Decision.IsUnchanged := FALSE;
  1218.       RETURN;
  1219.      END;
  1220.      END;
  1221.    END;
  1222.  
  1223.   END;
  1224.   END;
  1225.   END;
  1226.   IF (yyP29^.Decision.OneTest^.Kind = Tree.TestIsType) THEN
  1227.   IF (yyP28^.Rule.HasExit =  (TRUE)) THEN
  1228.   IF (yyP28^.Rule.HasAssign =  (TRUE)) THEN
  1229. (* line 302 "opt.puma" *)
  1230.    LOOP
  1231.      WITH yyP29^.Decision DO
  1232.      WITH yyP28^.Rule DO
  1233. (* line 306 "opt.puma" *)
  1234.       IF NOT (IsChanged (yyP29^.Decision.OneTest^.TestIsType.Path, yyP28^.Rule.Statements)) THEN EXIT; END;
  1235. (* line 307 "opt.puma" *)
  1236.       yyP29^.Decision.IsUnchanged := FALSE;
  1237.       RETURN;
  1238.      END;
  1239.      END;
  1240.    END;
  1241.  
  1242.   END;
  1243.   END;
  1244.   END;
  1245.   END;
  1246.  END UpdateChange;
  1247.  
  1248. PROCEDURE IsChanged (yyP31: Tree.tTree; yyP30: Tree.tTree): BOOLEAN;
  1249.  VAR yyTempo: RECORD CASE : INTEGER OF
  1250.  END; END;
  1251.  BEGIN
  1252.   IF (yyP30^.Kind = Tree.Assignment) THEN
  1253. (* line 312 "opt.puma" *)
  1254.    LOOP
  1255.      WITH yyP30^.Assignment DO
  1256. (* line 312 "opt.puma" *)
  1257.       IF NOT (yyP30^.Assignment.Object # NIL) THEN EXIT; END;
  1258. (* line 312 "opt.puma" *)
  1259.       IF NOT (IsSamePath (yyP31, yyP30^.Assignment.Object ^ . Formal . Path)) THEN EXIT; END;
  1260.       RETURN TRUE;
  1261.      END;
  1262.    END;
  1263.  
  1264.   END;
  1265.   IF Tree.IsType (yyP30, Tree.Statement) THEN
  1266. (* line 313 "opt.puma" *)
  1267.    LOOP
  1268.      WITH yyP30^.Statement DO
  1269. (* line 313 "opt.puma" *)
  1270.       IF NOT (IsChanged (yyP31, yyP30^.Statement.Next)) THEN EXIT; END;
  1271.       RETURN TRUE;
  1272.      END;
  1273.    END;
  1274.  
  1275.   END;
  1276.   RETURN FALSE;
  1277.  END IsChanged;
  1278.  
  1279. PROCEDURE FindCases (yyP32: Tree.tTree; VAR yyP35: Tree.tTree; VAR yyP34: SHORTCARD; VAR yyP33: tSet);
  1280.  VAR yyTempo: RECORD CASE : INTEGER OF
  1281.  | 1: yyR1: RECORD
  1282.   yyV1: Tree.tTree;
  1283.   yyV2: SHORTCARD;
  1284.   yyV3: tSet;
  1285.   yyV4: Tree.tTree;
  1286.   yyV5: SHORTCARD;
  1287.   yyV6: tSet;
  1288.   k: SHORTCARD;
  1289.   s: tSet;
  1290.   END;
  1291.  | 2: yyR2: RECORD
  1292.   yyV1: Tree.tTree;
  1293.   yyV2: SHORTCARD;
  1294.   yyV3: tSet;
  1295.   yyV4: Tree.tTree;
  1296.   yyV5: SHORTCARD;
  1297.   yyV6: tSet;
  1298.   k: SHORTCARD;
  1299.   s: tSet;
  1300.   END;
  1301.  | 3: yyR3: RECORD
  1302.   yyV1: Tree.tTree;
  1303.   yyV2: SHORTCARD;
  1304.   yyV3: tSet;
  1305.   yyV4: Tree.tTree;
  1306.   yyV5: SHORTCARD;
  1307.   yyV6: tSet;
  1308.   END;
  1309.  | 4: yyR4: RECORD
  1310.   yyV1: Tree.tTree;
  1311.   yyV2: SHORTCARD;
  1312.   yyV3: tSet;
  1313.   END;
  1314.  END; END;
  1315.  BEGIN
  1316.   IF (yyP32^.Kind = Tree.Decision) THEN
  1317.   IF (yyP32^.Decision.OneTest^.Kind = Tree.TestKind) THEN
  1318. (* line 317 "opt.puma" *)
  1319.     WITH yyTempo.yyR1 DO
  1320.      WITH yyP32^.Decision DO
  1321. (* line 321 "opt.puma" *)
  1322.       FindCases (yyP32^.Decision.Then, yyV1, yyV2, yyV3);
  1323. (* line 322 "opt.puma" *)
  1324.       MarkCases (yyP32^.Decision.Then, yyV2, yyV3);
  1325. (* line 323 "opt.puma" *)
  1326.       FindCases (yyP32^.Decision.Else, yyV4, yyV5, yyV6);
  1327. (* line 324 "opt.puma" *)
  1328.       ;
  1329. (* line 325 "opt.puma" *)
  1330.       
  1331.    IF yyV5 = 0 THEN
  1332.       k := 1;
  1333.       MakeSet (s, yyP32^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.TreeName^.TreeName.ClassCount);
  1334.       Assign (s, yyP32^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.Types);
  1335.    ELSIF IsSamePath (yyP32^.Decision.OneTest^.TestKind.Path, yyV4) AND IsDisjoint (yyV6, yyP32^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.Types) THEN
  1336.       k := yyV5 + 1;
  1337.       s := yyV6;
  1338.       Union (s, yyP32^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.Types);
  1339.    ELSE
  1340.       MarkCases (yyP32^.Decision.Else, yyV5, yyV6);
  1341.       k := 1;
  1342.       MakeSet (s, yyP32^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.TreeName^.TreeName.ClassCount);
  1343.       Assign (s, yyP32^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.Types);
  1344.    END;
  1345. ;
  1346.       yyP35 := yyP32^.Decision.OneTest^.TestKind.Path;
  1347.       yyP34 := k;
  1348.       yyP33 := s;
  1349.       RETURN;
  1350.      END;
  1351.     END;
  1352.  
  1353.   END;
  1354.   IF (yyP32^.Decision.OneTest^.Kind = Tree.TestIsType) THEN
  1355. (* line 317 "opt.puma" *)
  1356.     WITH yyTempo.yyR2 DO
  1357.      WITH yyP32^.Decision DO
  1358. (* line 321 "opt.puma" *)
  1359.       FindCases (yyP32^.Decision.Then, yyV1, yyV2, yyV3);
  1360. (* line 322 "opt.puma" *)
  1361.       MarkCases (yyP32^.Decision.Then, yyV2, yyV3);
  1362. (* line 323 "opt.puma" *)
  1363.       FindCases (yyP32^.Decision.Else, yyV4, yyV5, yyV6);
  1364. (* line 324 "opt.puma" *)
  1365.       ;
  1366. (* line 325 "opt.puma" *)
  1367.       
  1368.    IF yyV5 = 0 THEN
  1369.       k := 1;
  1370.       MakeSet (s, yyP32^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.TreeName^.TreeName.ClassCount);
  1371.       Assign (s, yyP32^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.Types);
  1372.    ELSIF IsSamePath (yyP32^.Decision.OneTest^.TestIsType.Path, yyV4) AND IsDisjoint (yyV6, yyP32^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.Types) THEN
  1373.       k := yyV5 + 1;
  1374.       s := yyV6;
  1375.       Union (s, yyP32^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.Types);
  1376.    ELSE
  1377.       MarkCases (yyP32^.Decision.Else, yyV5, yyV6);
  1378.       k := 1;
  1379.       MakeSet (s, yyP32^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.TreeName^.TreeName.ClassCount);
  1380.       Assign (s, yyP32^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.Types);
  1381.    END;
  1382. ;
  1383.       yyP35 := yyP32^.Decision.OneTest^.TestIsType.Path;
  1384.       yyP34 := k;
  1385.       yyP33 := s;
  1386.       RETURN;
  1387.      END;
  1388.     END;
  1389.  
  1390.   END;
  1391. (* line 342 "opt.puma" *)
  1392.     WITH yyTempo.yyR3 DO
  1393.      WITH yyP32^.Decision DO
  1394. (* line 343 "opt.puma" *)
  1395.       FindCases (yyP32^.Decision.Then, yyV1, yyV2, yyV3);
  1396. (* line 344 "opt.puma" *)
  1397.       MarkCases (yyP32^.Decision.Then, yyV2, yyV3);
  1398. (* line 345 "opt.puma" *)
  1399.       FindCases (yyP32^.Decision.Else, yyV4, yyV5, yyV6);
  1400. (* line 346 "opt.puma" *)
  1401.       MarkCases (yyP32^.Decision.Else, yyV5, yyV6);
  1402.       yyP35 := NIL;
  1403.       yyP34 := 0;
  1404.       
  1405.       RETURN;
  1406.      END;
  1407.     END;
  1408.  
  1409.   END;
  1410.   IF (yyP32^.Kind = Tree.Decided) THEN
  1411. (* line 348 "opt.puma" *)
  1412.     WITH yyTempo.yyR4 DO
  1413.      WITH yyP32^.Decided DO
  1414. (* line 349 "opt.puma" *)
  1415.       FindCases (yyP32^.Decided.Else, yyV1, yyV2, yyV3);
  1416. (* line 350 "opt.puma" *)
  1417.       MarkCases (yyP32^.Decided.Else, yyV2, yyV3);
  1418.       yyP35 := NIL;
  1419.       yyP34 := 0;
  1420.       
  1421.       RETURN;
  1422.      END;
  1423.     END;
  1424.  
  1425.   END;
  1426.   IF (yyP32^.Kind = Tree.NoDecision) THEN
  1427. (* line 352 "opt.puma" *)
  1428.       yyP35 := NIL;
  1429.       yyP34 := 0;
  1430.       
  1431.       RETURN;
  1432.  
  1433.   END;
  1434.  END FindCases;
  1435.  
  1436. PROCEDURE MarkCases (yyP38: Tree.tTree; yyP37: SHORTCARD; yyP36: tSet);
  1437.  VAR yyTempo: RECORD CASE : INTEGER OF
  1438.  END; END;
  1439.  BEGIN
  1440.   IF (yyP38^.Kind = Tree.Decision) THEN
  1441. (* line 356 "opt.puma" *)
  1442.    LOOP
  1443.      WITH yyP38^.Decision DO
  1444. (* line 356 "opt.puma" *)
  1445.       IF NOT (yyP37 >= 7) THEN EXIT; END;
  1446. (* line 356 "opt.puma" *)
  1447.       yyP38^.Decision.Cases := yyP37;
  1448. (* line 356 "opt.puma" *)
  1449.       ReleaseSet (yyP36);
  1450.       RETURN;
  1451.      END;
  1452.    END;
  1453.  
  1454.   END;
  1455.  END MarkCases;
  1456.  
  1457. PROCEDURE ElimDeadTests (yyP42: Tree.tTree; yyP41: Tree.tTree; yyP40: BOOLEAN; yyP39: tSet);
  1458.  VAR yyTempo: RECORD CASE : INTEGER OF
  1459.  | 1: yyR1: RECORD
  1460.   s: tSet;
  1461.   yyV1: Tree.tTree;
  1462.   yyV2: tSet;
  1463.   END;
  1464.  | 2: yyR2: RECORD
  1465.   s: tSet;
  1466.   yyV1: Tree.tTree;
  1467.   yyV2: tSet;
  1468.   END;
  1469.  | 3: yyR3: RECORD
  1470.   types: tSet;
  1471.   s2: tSet;
  1472.   yyV1: Tree.tTree;
  1473.   yyV2: tSet;
  1474.   END;
  1475.  | 4: yyR4: RECORD
  1476.   types: tSet;
  1477.   s2: tSet;
  1478.   yyV1: Tree.tTree;
  1479.   yyV2: tSet;
  1480.   END;
  1481.  | 5: yyR5: RECORD
  1482.   yyV1: Tree.tTree;
  1483.   yyV2: tSet;
  1484.   yyV3: Tree.tTree;
  1485.   yyV4: tSet;
  1486.   END;
  1487.  | 6: yyR6: RECORD
  1488.   yyV1: Tree.tTree;
  1489.   yyV2: tSet;
  1490.   END;
  1491.  END; END;
  1492.  BEGIN
  1493.   IF (yyP42^.Kind = Tree.Decision) THEN
  1494.   IF (yyP42^.Decision.OneTest^.Kind = Tree.TestKind) THEN
  1495.     WITH yyTempo.yyR1 DO
  1496.   IF (yyP40 =  (FALSE)) THEN
  1497. (* line 360 "opt.puma" *)
  1498.      WITH yyP42^.Decision DO
  1499. (* line 365 "opt.puma" *)
  1500.       ;
  1501. (* line 366 "opt.puma" *)
  1502.         MakeSet (s, yyP42^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.TreeName^.TreeName.ClassCount); IF IsDeadEnd (yyP42^.Decision.Then) THEN Assign (s, yyP42^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.Types); END; ;
  1503. (* line 367 "opt.puma" *)
  1504.       ElimDeadTests (yyP42^.Decision.Else, yyP42^.Decision.OneTest^.TestKind.Path, (TRUE), s);
  1505. (* line 368 "opt.puma" *)
  1506.       ElimDeadTests (yyP42^.Decision.Then, yyV1, (FALSE), yyV2);
  1507.       RETURN;
  1508.      END;
  1509.  
  1510.   END;
  1511.     END;
  1512. (* line 370 "opt.puma" *)
  1513.     WITH yyTempo.yyR3 DO
  1514.      WITH yyP42^.Decision DO
  1515. (* line 375 "opt.puma" *)
  1516.       ;
  1517. (* line 376 "opt.puma" *)
  1518.       
  1519.    s2 := yyP39;
  1520.    IF IsSamePath (yyP42^.Decision.OneTest^.TestKind.Path, yyP41) THEN
  1521.       IF NOT IsDisjoint (yyP42^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.Types, yyP39) THEN
  1522.      types := yyP42^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.Types;
  1523.      yyP42^.Decision.OneTest := mTestIsType (yyP42^.Decision.OneTest^.TestKind.Next, yyP42^.Decision.OneTest^.TestKind.Path, mNodeTypes (yyP42^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.TreeName, types), yyP42^.Decision.OneTest^.TestKind.Name);
  1524.      MakeSet (yyP42^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.Types, yyP42^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.TreeName^.TreeName.ClassCount);
  1525.      Assign (yyP42^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.Types, types);
  1526.      Difference (yyP42^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.Types, yyP39);
  1527.       END;
  1528.    ELSE
  1529.       AssignEmpty (s2);
  1530.    END;
  1531.    IF IsDeadEnd (yyP42^.Decision.Then) THEN Union (s2, yyP42^.Decision.OneTest^.TestKind.TypeDesc^.NodeTypes.Types); END;
  1532. ;
  1533. (* line 391 "opt.puma" *)
  1534.       ElimDeadTests (yyP42^.Decision.Else, yyP42^.Decision.OneTest^.TestKind.Path, (TRUE), s2);
  1535. (* line 392 "opt.puma" *)
  1536.       ElimDeadTests (yyP42^.Decision.Then, yyV1, (FALSE), yyV2);
  1537.       RETURN;
  1538.      END;
  1539.     END;
  1540.  
  1541.   END;
  1542.   IF (yyP42^.Decision.OneTest^.Kind = Tree.TestIsType) THEN
  1543.     WITH yyTempo.yyR2 DO
  1544.   IF (yyP40 =  (FALSE)) THEN
  1545. (* line 360 "opt.puma" *)
  1546.      WITH yyP42^.Decision DO
  1547. (* line 365 "opt.puma" *)
  1548.       ;
  1549. (* line 366 "opt.puma" *)
  1550.         MakeSet (s, yyP42^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.TreeName^.TreeName.ClassCount); IF IsDeadEnd (yyP42^.Decision.Then) THEN Assign (s, yyP42^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.Types); END; ;
  1551. (* line 367 "opt.puma" *)
  1552.       ElimDeadTests (yyP42^.Decision.Else, yyP42^.Decision.OneTest^.TestIsType.Path, (TRUE), s);
  1553. (* line 368 "opt.puma" *)
  1554.       ElimDeadTests (yyP42^.Decision.Then, yyV1, (FALSE), yyV2);
  1555.       RETURN;
  1556.      END;
  1557.  
  1558.   END;
  1559.     END;
  1560. (* line 370 "opt.puma" *)
  1561.     WITH yyTempo.yyR4 DO
  1562.      WITH yyP42^.Decision DO
  1563. (* line 375 "opt.puma" *)
  1564.       ;
  1565. (* line 376 "opt.puma" *)
  1566.       
  1567.    s2 := yyP39;
  1568.    IF IsSamePath (yyP42^.Decision.OneTest^.TestIsType.Path, yyP41) THEN
  1569.       IF NOT IsDisjoint (yyP42^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.Types, yyP39) THEN
  1570.      types := yyP42^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.Types;
  1571.      yyP42^.Decision.OneTest := mTestIsType (yyP42^.Decision.OneTest^.TestIsType.Next, yyP42^.Decision.OneTest^.TestIsType.Path, mNodeTypes (yyP42^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.TreeName, types), yyP42^.Decision.OneTest^.TestIsType.Name);
  1572.      MakeSet (yyP42^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.Types, yyP42^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.TreeName^.TreeName.ClassCount);
  1573.      Assign (yyP42^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.Types, types);
  1574.      Difference (yyP42^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.Types, yyP39);
  1575.       END;
  1576.    ELSE
  1577.       AssignEmpty (s2);
  1578.    END;
  1579.    IF IsDeadEnd (yyP42^.Decision.Then) THEN Union (s2, yyP42^.Decision.OneTest^.TestIsType.TypeDesc^.NodeTypes.Types); END;
  1580. ;
  1581. (* line 391 "opt.puma" *)
  1582.       ElimDeadTests (yyP42^.Decision.Else, yyP42^.Decision.OneTest^.TestIsType.Path, (TRUE), s2);
  1583. (* line 392 "opt.puma" *)
  1584.       ElimDeadTests (yyP42^.Decision.Then, yyV1, (FALSE), yyV2);
  1585.       RETURN;
  1586.      END;
  1587.     END;
  1588.  
  1589.   END;
  1590. (* line 394 "opt.puma" *)
  1591.     WITH yyTempo.yyR5 DO
  1592.      WITH yyP42^.Decision DO
  1593. (* line 395 "opt.puma" *)
  1594.         IF yyP40 THEN ReleaseSet (yyP39); END; ;
  1595. (* line 396 "opt.puma" *)
  1596.       ElimDeadTests (yyP42^.Decision.Else, yyV1, (FALSE), yyV2);
  1597. (* line 397 "opt.puma" *)
  1598.       ElimDeadTests (yyP42^.Decision.Then, yyV3, (FALSE), yyV4);
  1599.       RETURN;
  1600.      END;
  1601.     END;
  1602.  
  1603.   END;
  1604.   IF (yyP42^.Kind = Tree.Decided) THEN
  1605. (* line 399 "opt.puma" *)
  1606.     WITH yyTempo.yyR6 DO
  1607.      WITH yyP42^.Decided DO
  1608. (* line 400 "opt.puma" *)
  1609.         IF yyP40 THEN ReleaseSet (yyP39); END; ;
  1610. (* line 401 "opt.puma" *)
  1611.         IF NOT yyP42^.Decided.Rule^.Rule.HasExit THEN ReportWarning (yyP42^.Decided.Else); END; ;
  1612. (* line 402 "opt.puma" *)
  1613.       ElimDeadTests (yyP42^.Decided.Else, yyV1, (FALSE), yyV2);
  1614.       RETURN;
  1615.      END;
  1616.     END;
  1617.  
  1618.   END;
  1619.   IF (yyP42^.Kind = Tree.NoDecision) THEN
  1620.   IF (yyP40 =  (TRUE)) THEN
  1621. (* line 404 "opt.puma" *)
  1622.      WITH yyP42^.NoDecision DO
  1623. (* line 405 "opt.puma" *)
  1624.       ReleaseSet (yyP39);
  1625.       RETURN;
  1626.      END;
  1627.  
  1628.   END;
  1629.   END;
  1630.  END ElimDeadTests;
  1631.  
  1632. PROCEDURE IsDeadEnd (yyP43: Tree.tTree): BOOLEAN;
  1633.  VAR yyTempo: RECORD CASE : INTEGER OF
  1634.  END; END;
  1635.  BEGIN
  1636.   IF (yyP43^.Kind = Tree.Decided) THEN
  1637. (* line 410 "opt.puma" *)
  1638.    LOOP
  1639.      WITH yyP43^.Decided DO
  1640. (* line 410 "opt.puma" *)
  1641.       IF NOT (NOT yyP43^.Decided.Rule^.Rule.HasExit OR IsDeadEnd (yyP43^.Decided.Else)) THEN EXIT; END;
  1642.       RETURN TRUE;
  1643.      END;
  1644.    END;
  1645.  
  1646.   END;
  1647.   RETURN FALSE;
  1648.  END IsDeadEnd;
  1649.  
  1650. PROCEDURE ReportWarning (yyP44: Tree.tTree);
  1651.  VAR yyTempo: RECORD CASE : INTEGER OF
  1652.  END; END;
  1653.  BEGIN
  1654.   IF (yyP44^.Kind = Tree.Decided) THEN
  1655. (* line 414 "opt.puma" *)
  1656.      WITH yyP44^.Decided DO
  1657. (* line 415 "opt.puma" *)
  1658.       Warning ("unreachable code", yyP44^.Decided.Rule^.Rule.Line);
  1659. (* line 416 "opt.puma" *)
  1660.       ReportWarning (yyP44^.Decided.Else);
  1661.       RETURN;
  1662.      END;
  1663.  
  1664.   END;
  1665.   IF (yyP44^.Kind = Tree.Decision) THEN
  1666. (* line 418 "opt.puma" *)
  1667.      WITH yyP44^.Decision DO
  1668. (* line 419 "opt.puma" *)
  1669.       ReportWarning (yyP44^.Decision.Then);
  1670. (* line 420 "opt.puma" *)
  1671.       ReportWarning (yyP44^.Decision.Else);
  1672.       RETURN;
  1673.      END;
  1674.  
  1675.   END;
  1676.  END ReportWarning;
  1677.  
  1678. PROCEDURE BeginOptimize;
  1679.  BEGIN
  1680.  END BeginOptimize;
  1681.  
  1682. PROCEDURE CloseOptimize;
  1683.  BEGIN
  1684.  END CloseOptimize;
  1685.  
  1686. PROCEDURE yyExit;
  1687.  BEGIN
  1688.   IO.CloseIO; System.Exit (1);
  1689.  END yyExit;
  1690.  
  1691. BEGIN
  1692.  yyf    := IO.StdOutput;
  1693.  Exit    := yyExit;
  1694.  BeginOptimize;
  1695. END Optimize.
  1696.